package main

import (
	"fmt"
	"math/rand"
)

func main() {

	source := make([]int, 0, 10)

	//rand.Seed(time.Now().UnixNano())

	for i := 0; i < 100; i++ {

		source = append(source, rand.Intn(1000))
	}

	fmt.Println(source)

	bubble_sort(source)

	fmt.Println(source)

}

func bubble_sort(souce []int) {

	len := len(souce)

	exchang := false
	for i := 0; i < len-1; i++ {
		exchang = false
		for j := 0; j < len-1-i; j++ {
			if souce[j] > souce[j+1] {
				souce[j], souce[j+1] = souce[j+1], souce[j]
				exchang = true
			}
		}

		if !exchang {

			return
		}
	}

}
